//
//  GSYNetworkManager+Extension.swift
//  GSY-微博-swift
//
//  Created by Song on 2017/12/6.
//  Copyright © 2017年 Song. All rights reserved.
//

import Foundation

// MARK: - 封装新浪微博的网络请求方法
extension GSYNetworkManager {
    
    /// 加载微博数据字典数组
    ///
    /// - Parameter completion: 完成回调 [list：微博字典数组/ 是否成功]
    func statusList(completion:@escaping (_ list:[[String:Any]]? ,_ isSuccess: Bool)->()) {
        
        // 用 网络工具 加载微博数据
        let urlStrin = "https://api.weibo.com/2/statuses/home_timeline.json";
        let params = ["access_token":"2.00pYuOLGztMQRB3a7b65698c0rj1nw"];
        
        request(URLString: urlStrin, parameters: params) { (json, isSuccess) in
//            print(json);
            
            // 从json中获取statuses字典数组
            let result = json?["statuses"] as? [[String: Any]]; // 报错 - 2017/12/27
            
            completion(list:result, isSuccess: isSuccess);
        }
    }
    
}
